package com.jxm.validation;

import com.jxm.annotation.Username;
import com.jxm.utils.RegexUtil;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class UsernameValidator implements ConstraintValidator<Username, String> {
    @Override
    public boolean isValid(String text, ConstraintValidatorContext constraintValidatorContext) {
        if (text == null || text == "" || text.trim().length() <= 0) {
            return false;
        }
        return RegexUtil.isUserName(text);
    }
}
